package com.i2works.smartluolong.utils.shiro.permission;

import org.apache.shiro.authz.Permission;
import org.apache.shiro.authz.permission.PermissionResolver;
import org.apache.shiro.authz.permission.WildcardPermission;

/**
 * 权限字符串解析
 *
 * @author koal <koal@vip.qq.com>
 * @date 2016/1/17 15:27
 */
public class UrlPermissionResolver implements PermissionResolver {

    // PermissionResolver把字符串转换成相应的Permission实例
    @Override
    public Permission resolvePermission(String permissionString) {
        if (permissionString.startsWith("/")) {
            return new UrlPermission(permissionString);
        }
        return new WildcardPermission(permissionString);
    }
}
